<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.4"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>miniFOC: algorithm/filter.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectlogo"><img alt="Logo" src="Acme_LOGO.png"/></td>
  <td id="projectalign">
   <div id="projectname">miniFOC<span id="projectnumber">&#160;1.0.3</span>
   </div>
   <div id="projectbrief">This open-source project aims to accomplish a FOC(Field Oriented Control) scheme that is operatable with minimum costs in China.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_99d3723365464dd656f512988bb8dbbd.html">algorithm</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#func-members">Functions</a> &#124;
<a href="#var-members">Variables</a>  </div>
  <div class="headertitle"><div class="title">filter.h File Reference</div></div>
</div><!--header-->
<div class="contents">

<p>this is the header file of <a class="el" href="filter_8c.html" title="this file contains the code implementation of first-order digital RC low-pass filter algorithm and th...">filter.c</a>, which defines the structure of filter algorithm.  
<a href="#details">More...</a></p>

<p><a href="filter_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_filter___structure__t.html">Filter_Structure_t</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">structure of low-pass filter algorithm  <a href="struct_filter___structure__t.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a687b2ec6984ce9fa9d08189a3e7e1592"><td class="memItemLeft" align="right" valign="top">float&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="filter_8h.html#a687b2ec6984ce9fa9d08189a3e7e1592">filter_update_value</a> (<a class="el" href="struct_filter___structure__t.html">Filter_Structure_t</a> *param, short value)</td></tr>
<tr class="memdesc:a687b2ec6984ce9fa9d08189a3e7e1592"><td class="mdescLeft">&#160;</td><td class="mdescRight">update the output value of the first-order low-pass filter  <a href="filter_8h.html#a687b2ec6984ce9fa9d08189a3e7e1592">More...</a><br /></td></tr>
<tr class="separator:a687b2ec6984ce9fa9d08189a3e7e1592"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa1e7128fffcf2b56a6fb1c23f89afd75"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="filter_8h.html#aa1e7128fffcf2b56a6fb1c23f89afd75">filter_config</a> (void)</td></tr>
<tr class="memdesc:aa1e7128fffcf2b56a6fb1c23f89afd75"><td class="mdescLeft">&#160;</td><td class="mdescRight">configure low-pass filter parameters  <a href="filter_8h.html#aa1e7128fffcf2b56a6fb1c23f89afd75">More...</a><br /></td></tr>
<tr class="separator:aa1e7128fffcf2b56a6fb1c23f89afd75"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="var-members" name="var-members"></a>
Variables</h2></td></tr>
<tr class="memitem:a70331d536c7d5e99a76bd8651fd6b714"><td class="memItemLeft" align="right" valign="top">volatile <a class="el" href="struct_filter___structure__t.html">Filter_Structure_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="filter_8h.html#a70331d536c7d5e99a76bd8651fd6b714">velocity_filter</a></td></tr>
<tr class="memdesc:a70331d536c7d5e99a76bd8651fd6b714"><td class="mdescLeft">&#160;</td><td class="mdescRight">motor rotation speed low pass filter handle  <a href="filter_8h.html#a70331d536c7d5e99a76bd8651fd6b714">More...</a><br /></td></tr>
<tr class="separator:a70331d536c7d5e99a76bd8651fd6b714"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p >this is the header file of <a class="el" href="filter_8c.html" title="this file contains the code implementation of first-order digital RC low-pass filter algorithm and th...">filter.c</a>, which defines the structure of filter algorithm. </p>
<dl class="section author"><dt>Author</dt><dd>Lao·Zhu </dd></dl>
<dl class="section version"><dt>Version</dt><dd>V1.0.1 </dd></dl>
<dl class="section date"><dt>Date</dt><dd>9. October 2021 </dd></dl>

<p class="definition">Definition in file <a class="el" href="filter_8h_source.html">filter.h</a>.</p>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="aa1e7128fffcf2b56a6fb1c23f89afd75" name="aa1e7128fffcf2b56a6fb1c23f89afd75"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa1e7128fffcf2b56a6fb1c23f89afd75">&#9670;&nbsp;</a></span>filter_config()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void filter_config </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>configure low-pass filter parameters </p>

<p class="definition">Definition at line <a class="el" href="filter_8c_source.html#l00045">45</a> of file <a class="el" href="filter_8c_source.html">filter.c</a>.</p>

<p class="reference">References <a class="el" href="filter_8c_source.html#l00028">filter_coefficient_config()</a>, <a class="el" href="foc_8h_source.html#l00028">SPEED_COEFFICIENT</a>, <a class="el" href="config_8h_source.html#l00032">SPEED_UP_FREQ</a>, <a class="el" href="config_8h_source.html#l00030">TIM13_FREQUENCY</a>, and <a class="el" href="filter_8c_source.html#l00019">velocity_filter</a>.</p>

<p class="reference">Referenced by <a class="el" href="main_8c_source.html#l00139">main()</a>.</p>

</div>
</div>
<a id="a687b2ec6984ce9fa9d08189a3e7e1592" name="a687b2ec6984ce9fa9d08189a3e7e1592"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a687b2ec6984ce9fa9d08189a3e7e1592">&#9670;&nbsp;</a></span>filter_update_value()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">float filter_update_value </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_filter___structure__t.html">Filter_Structure_t</a> *&#160;</td>
          <td class="paramname"><em>param</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">short&#160;</td>
          <td class="paramname"><em>value</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>update the output value of the first-order low-pass filter </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">param</td><td>first order low pass filter parameter handler </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">value</td><td>the sampled value to be filtered at this moment </td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">current</td><td>calculation results of low-pass filter </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="filter_8c_source.html#l00056">56</a> of file <a class="el" href="filter_8c_source.html">filter.c</a>.</p>

<p class="reference">References <a class="el" href="filter_8h_source.html#l00017">Filter_Structure_t::coefficient1</a>, <a class="el" href="filter_8h_source.html#l00018">Filter_Structure_t::coefficient2</a>, <a class="el" href="filter_8h_source.html#l00020">Filter_Structure_t::current_result</a>, and <a class="el" href="filter_8h_source.html#l00019">Filter_Structure_t::last_result</a>.</p>

<p class="reference">Referenced by <a class="el" href="encoder_8c_source.html#l00106">encoder_update_speed()</a>.</p>

</div>
</div>
<h2 class="groupheader">Variable Documentation</h2>
<a id="a70331d536c7d5e99a76bd8651fd6b714" name="a70331d536c7d5e99a76bd8651fd6b714"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a70331d536c7d5e99a76bd8651fd6b714">&#9670;&nbsp;</a></span>velocity_filter</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">volatile <a class="el" href="struct_filter___structure__t.html">Filter_Structure_t</a> velocity_filter</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">extern</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>motor rotation speed low pass filter handle </p>

<p class="definition">Definition at line <a class="el" href="filter_8c_source.html#l00019">19</a> of file <a class="el" href="filter_8c_source.html">filter.c</a>.</p>

<p class="reference">Referenced by <a class="el" href="encoder_8c_source.html#l00106">encoder_update_speed()</a>, and <a class="el" href="filter_8c_source.html#l00045">filter_config()</a>.</p>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.4
</small></address>
</body>
</html>
